Fail to scroll if the given mark is not in text view's current buffer
authorKristian Rietveld <kris@gtk.org>
Fri, 4 Sep 2009 11:34:56 +0000 (13:34 +0200)
committerKristian Rietveld <kris@gtk.org>
Fri, 4 Sep 2009 12:06:58 +0000 (14:06 +0200)
In gtk_text_view_queue_scroll() we need to verify if the given mark
exists in the text view's current buffer.  When not done, this can
result in corruption of the BTree data structure.  Patch merged from
maemo-gtk.

gtk/gtktextview.c

index 4c5f0d233d9ea3ff0d66848b2ea8ca1faf4b28b8..ad04480d47204b3dacd602e0d2a9999d84b4e81a 100644 (file)
@@ -1894,6 +1894,7 @@ gtk_text_view_queue_scroll (GtkTextView   *text_view,
                             gdouble        xalign,
                             gdouble        yalign)
 {
+  const char *mark_name;
   GtkTextIter iter;
   GtkTextPendingScroll *scroll;
 
@@ -1906,6 +1907,12 @@ gtk_text_view_queue_scroll (GtkTextView   *text_view,
   scroll->xalign = xalign;
   scroll->yalign = yalign;
   
+  /* We need to verify that the buffer contains the mark, otherwise this
+   * can lead to data structure corruption later on.
+   */
+  mark_name = gtk_text_mark_get_name (mark);
+  g_return_if_fail (gtk_text_buffer_get_mark (get_buffer (text_view), mark_name));
+
   gtk_text_buffer_get_iter_at_mark (get_buffer (text_view), &iter, mark);
 
   scroll->mark = gtk_text_buffer_create_mark (get_buffer (text_view),